package com.ycy;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import lombok.extern.slf4j.Slf4j;

import java.util.ArrayList;
import java.util.List;

@Slf4j
public class GenericDataListener  extends AnalysisEventListener<Object> {

    private List<Object> dataList = new ArrayList<>();

    @Override
    public void invoke(Object data, AnalysisContext context) {
        log.info("row index -> {}", context.readRowHolder().getRowIndex());
        dataList.add(data);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext context) {
        // 读取完成后的操作
        System.out.println("所有数据读取完成！");
    }

    public List<Object> getDataList() {
        return dataList;
    }
}